package com.gxa.controller.xiaohuocontroller;

import com.gxa.common.R;
import com.gxa.pojo.XiaoHuoDan;
import com.gxa.pojo.XiaoHuoDanShangPin;
import com.gxa.service.xiaohuoservice.XiaoHuoDanService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;

/**
 * @version 1.0
 * @Author fluoxetine
 * @Date 2022/3/31 10:42
 **/
@RestController
@RequestMapping("/XiaoHuo/xiaoHuoDanJiLu")
@Api(value = "销货管理" , tags = "销货单记录数据接口API")
@RequiresPermissions("销货单记录")
public class XiaoHuoDanJiLuController {
    @Autowired
    private XiaoHuoDanService xiaoHuoDanService;

    @GetMapping(value = "/selectXiaoShouHuoDanJiLu")
    @ApiOperation(value = "销货单记录查询接口",notes = "接受参数，根据参数返回销售明细",httpMethod = "get", response =R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始日期，默认当月1号", required = true, dataType = "date", paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束日期，默认当月最后一天", required = true, dataType = "date", paramType = "query"),
            @ApiImplicitParam(name = "keHuId",value = "客户id",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "shangPinId",value = "商品id",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "cangKuId",value = "仓库id",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "zhiYuanId",value = "职员id",paramType = "query",dataType = "String",required = false)
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务器错误")
    })
    public R selectXiaoShouHuoDanJiLu(@RequestParam String startTime,
                                      @RequestParam String endTime,
                                      @RequestParam(required = false) String keHuId,
                                      @RequestParam(required = false) String shangPinId,
                                      @RequestParam(required = false) String cangKuId,
                                      @RequestParam(required = false) String zhiYuanId) {
        return xiaoHuoDanService.selectXiaoShouHuoDanJiLu(startTime,endTime,keHuId,shangPinId,cangKuId,zhiYuanId);
    }

    @RequestMapping(value = "/shenHe", method = RequestMethod.POST)
    @ApiOperation(value = "销货单订单记录审核接口", notes = "提供当前页码数与每页显示条数", httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "销货单订单记录id", required = true, dataType = "int", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务器错误")
    })
    public R shenHe(String id) {
        R r = new R();
        r.setCode(200);
        r.setMsg("审核成功");
        return r;
    }

    @RequestMapping(value = "/fanShenHe", method = RequestMethod.POST)
    @ApiOperation(value = "销货单订单记录反审核接口", notes = "提供当前页码数与每页显示条数", httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "销货单订单记录id", required = true, dataType = "int", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务器错误")
    })
    public R fanShenHe(String id) {
        R r = new R();
        r.setCode(200);
        r.setMsg("反审核成功");
        return r;
    }

    @RequestMapping(value = "/delXiaoHuoDanJiLuById", method = RequestMethod.POST)
    @ApiOperation(value = "销货单订单记录删除接口", notes = "提供当前页码数与每页显示条数", httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "销货单订单记录id", required = true, dataType = "int", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务器错误")
    })
    public R delXiaoHuoDanJiLuById(int id) {
        return xiaoHuoDanService.delXiaoHuoDanJiLuById(id);
    }

    @RequestMapping(value = "/updateXiaoHuoDanJiLuById",method = RequestMethod.POST)
    @ApiOperation(value = "修改销货单订单信息接口",notes = "提供当前页码数与每页显示条数",httpMethod = "post",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "要修改的id",required = true,dataType = "int",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "请求成功"),
            @ApiResponse(code=404,message = "找不到页面"),
            @ApiResponse(code=500,message = "后台服务器错误")
    })
    public R updateXiaoHuoDanJiLuById(XiaoHuoDan xiaoHuoDan){
        return xiaoHuoDanService.updateXiaoHuoDanJiLuById(xiaoHuoDan);
    }
}